<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<input type="text" id="input1" />+
		<input type="text" id="input2" />
		<input type="button" value="=" onclick="add()"/>
		<span id="resultSpan"></span>
		<script type="text/javascript">
			// parseInt()  将字符串转换为number整数
			// parseFloat() 将字符串转换为number浮点数
			function add()
			{
				var input1 = document.getElementById("input1");
				var num1 = parseInt(input1.value);
				var input2 = document.getElementById("input2");
				var num2 = parseInt(input2.value);
				var num3 = num1+num2;
				var resultSpan = document.getElementById("resultSpan");
				resultSpan.innerHTML = num3;
			}
			
		</script>
		
		
	</body>
</html>
